<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>人脸识别</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link href="__CSSN__/style.css" rel="stylesheet" type="text/css">
    <!-- 	<link rel="stylesheet" href="lib/helang-mobile.css"> -->
    <link rel="stylesheet" href="__CSSN__/index.css">
    <style type="text/css"></style>
</head>
<body style="">
<section class="jq22-flexView">
    <header class="jq22-navBar jq22-navBar-fixed b-line">
        <a href="javascript:history.back(-1);" class="jq22-navBar-item">
            <i class="icon icon-return"></i>
        </a>
        <div class="jq22-center">
            <span class="jq22-center-title">人脸识别</span>
        </div>
        <a href="javascript:;" class="jq22-navBar-item">
            <i class="icon icon-sys"></i>
        </a>
    </header>
    <section class="jq22-scrollView">

        <div class="jq22-auto-form">
            <div class="jq22-auto-box">

                <form action="" id="form1" class="jq22-auto-inp" method="post" onsubmit="return false;">
                    <div id="show" >

                        <div class="jq22-flex">
                            <label>联系电话</label>
                            <div class="jq22-flex-box">
                                <input type="number" name="mobile" placeholder="请输入您的联系电话">
                            </div>
                        </div>




                    </div>



                    <button class="jq22-apply-btn" onclick="binding()">查询</button>
                </form>
            </div>
        </div>
    </section>
</section>

<script src="__JSN__/jquery.min.js"></script>

<script type="text/javascript" src="__STATICN__/layer_mobile/layer.js"></script>
<script>
    /**
     * 提交表单
     */
    function binding(){
        var mobile = $("input[name='mobile']").val();
        $.ajax({
            url:"{:url('index/searchUser')}",
            dataType:'json',
            type:'POST',
            async: true,
            data: {'mobile':mobile,'ajax':1},
            success: function(data){
                if (data.error_code < 1) {
                    var re = data.result;
                    location.href = data.url;


                }else{
                    layer.open({
                        content: data.error_msg
                        ,skin: 'msg'
                        ,time: 3 //2秒后自动关闭

                    });


                }
                // layer.closeAll()

            },
            error:function(response){
                console.log(response);
                layer.closeAll()
            }
        });

    }
    /**
     * 上传图片
     */
    $("#preview-file").change(function(){
        var  i = layer.open({
            type: 2
            ,content: '搜索中'
        });
        var formData = new FormData();


        formData.append("img",$('#preview-file')[0].files[0]);
        formData.append("ajax",1);

        $.ajax({
            url:"{:url('index/searchFace')}",
            dataType:'json',
            type:'POST',
            async: true,
            data: formData,
            processData : false, // 使数据不做处理
            contentType : false, // 不要设置Content-Type请求头
            success: function(data){
                if (data.error_code < 1) {
                    var re = data.result;
                    layer.open({
                        content: '查询成功'
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                        ,success:function(){
                            $("#show").show();
                            $("input[name='username']").val(re.username)
                            $("input[name='card_num']").val(re.card_num)
                            $("input[name='age']").val(re.age)
                            $("input[name='com_name']").val(re.com_name)
                            $("input[name='mobile']").val(re.mobile)
                            $("input[name='renshu']").val(re.renshu)
                            $("#preview-img").attr('src','/'+re.head_pic)

                            layer.close(i)
                        }
                    });


                }else{
                    layer.open({
                        content: '暂无该会员'
                        ,skin: 'msg'
                        ,time: 3 //2秒后自动关闭
                        ,success:function(){

                            $("#show").hide();
                            layer.close(i)
                        }
                    });


                }
                // layer.closeAll()

            },
            error:function(response){
                console.log(response);
                layer.closeAll()
            }
        });
    })
</script>
</body>
</html>

